/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.api.actioninterface;

import com.inspur.edp.bef.bizentity.operation.BizOperation;
import com.inspur.edp.bef.component.base.GspComponent;
import com.inspur.edp.bef.component.detailcmpentity.bemgr.BEMgrMethod;
import com.inspur.edp.bef.component.detailcmpentity.vm.VMMethod;
import com.inspur.edp.bff.designtime.generator.api.VmApiGenContext;
import com.inspur.edp.bff.designtime.generator.api.actioninterface.method.ActionInterfaceMethodGenerator;
import com.inspur.edp.bff.designtime.generator.api.actioninterface.method.MgrActionBuildUtil;
import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrInterfaceGeneratorContext;
import com.inspur.edp.das.commonmodel.IGspCommonModel;
import com.inspur.edp.formserver.viewmodel.action.MappedCdpAction;
import com.inspur.edp.formserver.viewmodel.action.ViewModelAction;
import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;

public class ActionInterfaceGenerator extends MgrInterfaceGenerator {

  ///#region BasicInfo
  private VmApiGenContext apiGenCtx;

  public ActionInterfaceGenerator(VmApiGenContext apiGenCtx) {
    super(apiGenCtx);
    this.apiGenCtx = apiGenCtx;
  }

  public static String getItemName(IGspCommonModel model) {
    return  "I"+ model.getCode()+"Manager";
  }

  @Override
  protected MgrInterfaceGeneratorContext createMgrInterfaceGenContext() {
    return new VoMgrInterfaceGenCtx(apiGenCtx);
  }

  @Override
  protected java.util.ArrayList<ModifierKeyword> getAccessModifier() {
    return new java.util.ArrayList<ModifierKeyword>(
        java.util.Arrays.asList(ModifierKeyword.PUBLIC_KEYWORD));
  }

  //C# TO JAVA CONVERTER TODO TASK: Lambda expressions and anonymous methods are not converted by C# to Java Converter:
  @Override
  protected String getName() {
    return apiGenCtx.getVmGenContext().getVm().getMgrInterfaceName();
  } //GetItemName(apiGenCtx.VmGenContext.Vm);

  ///#endregion

  ///#endregion

  ///#region ChildGenerators
  @Override
  protected java.util.ArrayList<BaseGenerator> createChildGenerators() {
    java.util.ArrayList<BaseGenerator> childGenerators = super.createChildGenerators();
    if (childGenerators == null) {
      childGenerators = new java.util.ArrayList<BaseGenerator>();
    }
    MgrActionBuildUtil.addActionGenertors(apiGenCtx, childGenerators);
    return childGenerators;
  }

  ///#endregion

  ///#region NonOfUse
  //protected override List<Type> addUsings() { return null; }
  @Override
  protected void doInitialize() {
    apiGenCtx.setVmActionInterfaceType(new MediateType(compileUnit.getPackageName(), getName()));
  }

  ///#endregion

  ///#region private


//  @Override
//  protected java.util.ArrayList<TypeInfo> addParentInterfaces() {
//    if (apiGenCtx.getCommonModel().isSimplifyGen()) {
//      return new ArrayList<>(Arrays.asList(new TypeInfo(IFSManager.class)));
//    }
//    return null;
//  }
  ///#endregion
}
